<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p>姓名:{{ person.name }}</p>
    <p>年龄:{{ person.age }}</p>
    <input type="button" value="长大" @click="upAge">
  </div>

  <script src="./js/vue.js"></script>
  <script>

    let vm = new Vue({
      el: "#app",
      data: {
        person: {
          name: "cy",
          age: 15
        }
      },
      watch: {
        person: {
          handler: function () {
            console.log("person变了");
          },
          deep: true,
          immediate: true
        }
      },
      methods: {
        upAge() {
          this.person.age++;
        }
      }
    });

  </script>

</body>
</html>